<?php
/*
 * This file is part of SoftSite.
 *
 * (c) 2012 Steve Tredinnick
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 *
 *
 * @package softsite
 * @author  Steve Tredinnick <steve.tredinnick@gmail.com>
 */

namespace Classes;

use Lib\Forms\Form;

class BaseView
{
    protected $view;
    
    /*
     * @var $form Form variable to hold form data.
     */
    protected $form;
    protected $viewData;
    protected $template;
    protected $urlValues;
    protected $action;
    protected $controller;
    protected $id;


    public function __construct($action, $urlValues)
    {
        $this->view = new \Smarty();

        $this->view->setTemplateDir('views');
        $this->view->setCompileDir('views_c');
        $this->view->setCacheDir('lib/Smarty/cache');
        $this->view->setConfigDir('lib/Smarty/config');

        $this->form = new Form();

    }

    protected function ReturnView()
    {
        if(is_null($this->template))
        {
            return $this->controller . '/' . $this->action . '.tpl';
        }
        else
        {
            return $this->controller . '/' . $this->template . '.tpl';
        }
    }

    protected function DisplayView()
    {
        $this->view->display("header.tpl");
        $this->view->display($this->ReturnView());
        $this->view->display("footer.tpl");
    }

    protected function RenderFormToTemplate()
    {
        $this->view->assign($this->form->getFormName(),$this->form->GetFormRender());
    }
}
